import requests
import baozou_insert_sql
import re
r = requests.session()
url = "https://cps.baozoukanshu.com/admin/login.html"

date ={
    "username" : "",
    "password" : ""

}
Platform = "暴走1"
    # elif i ==2:
    #     date ={
    #         "username" : "",
    #         "password" : ""
    #     }
    #     Platform = "暴走2"
    # else:
    #     date ={
    #         "username": "",
    #         "password": ""
    #     }
    #     Platform = "暴走3"

rr = r.post(url = url,data = date)

header = {
    "Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8",
    "Accept-Encoding": "gzip, deflate, br",
    "Accept-Language": "zh-CN,zh;q=0.9",
    "Connection": "keep-alive",
    "Cookie": "aliyungf_tc=AQAAAGehVjyv4QkAHKJqtKhuCV0SPa/E; PHPSESSID=tohirk2ign2nt6bpft4lbemkb7",
    "Host": "www.bzcps.com",
    "Referer": "https://www.bzcps.com/index/report/dayincome.html",
    "Upgrade-Insecure-Requests": "1",
    "User-Agent": "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/68.0.3440.84 Safari/537.36"
}
aa = r.get(url="https://www.bzcps.com/index/report/dayincome.html",headers = header)

aa = aa.text.replace('\n','').replace('\t','').replace('\r','')
date_time = re.findall('<div class="mn mn1">(.*?)充值',aa)
print(date_time[1])

Amount_share = re.findall('<div class="mn mn2">昨日分成.*?￥</em>(.*?)</p></div>',aa)
print(Amount_share[0])

#数据入库
try:
        baozou_insert_sql.baozou_spider_everyday_sum(date_time[1],Amount_share[0],Platform)
except  Exception:
        print("数据入库失败")

# time.sleep(600)